from rest_framework.parsers import BaseParser

# 定义自己的解析器
# key1=val1:key2=val2:key3=val3
class P1902Parser(BaseParser):
    media_type = "text/p1902"


    def parse(self, stream, media_type=None, parse_context=None):
        data_dict = {}
        data = stream.read().decode("utf-8")
        for keyval in data.split(":"):
            key, val = keyval.split("=")
            data_dict[key] = val

        return data_dict


